package test;

public class Sieve {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Sieve of Eratosthenes - Lua Benchmark test 0.00001");
		System.out.println("Starting test .....");
		double start = System.nanoTime() * 1e-9;
		sieve(100000);
		double stop = System.nanoTime() * 1e-9;
		System.out.println("Done!");
		System.out.println("Total Time = " + (stop - start) + " seconds");
	}
	
	private static void sieve(int n) {
	  int x[] = new int[100002];
	  int iter = 0;
	  do {
	    x[1] = 0;
	    int i = 2;
	    do {
	      x[i] = 1;
	      i = i + 1;
	    } while (!(i > n));
	    int p = 2;
	    while(p * p <= n) {
	      int j = p;
	      while(j <= n) {
	        x[j] = 0;
	        j = j + p;
	      }
	      do {
	        p = p + 1;
	      } while (!(x[p] == 1));
	    }
	    iter = iter + 1;
	  }while (!(iter == 101));
	}
}
